@extends('layouts.app')

@section('content')
    <script src="/static/plugins/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <link href="static/css/home/member.css?v=<?php echo time()?>" rel="stylesheet">
    <style>
        .layui-form-title {
            float: left;
            color: #666;
            display: block;
            width: 100px;
            font-weight: 400;
            line-height: 20px;
            text-align: right;
        }

        .block-name {
            font-size: 24px;
            height: 40px;
            margin-bottom: 5px
        }
    </style>
    <div class="container">
        <div class="menu">
            <a href="{{url('/')}}">首页</a> > <a href="{{url('/member')}}">个人中心</a>
        </div>
        <div class="warp member">
            @include('common.left')
            <div class="resume" style="min-height: 900px">
                @include('layouts.resume.basis')
                @include('layouts.resume.intention')
                @include('layouts.resume.job')
                {{--@include('resume.education')--}}
            </div>


        </div>


    </div>
    <script>
        layui.use(['jquery', 'form', 'layedit', 'laydate'], function () {
            let form = layui.form;
            let layer = layui.layer;
            let $ = layui.jquery;
            let laydate = layui.laydate;
            //监听提交
            form.on('submit(modal-basis)', function (data) {
                alert(1);
                console.log(data);
                //ajax
                //ajaxEditResume(data.field, $(this));
                return true;
            });
            form.on('submit(modal-basis)', function (data) {
                console.log(data);
                //ajax
                //ajaxEditResume(data.field, $(this));
                return true;
            });
            form.on('submit(modal-job)', function (data) {
                console.log(data);
                $.ajax({
                    type: "Post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    url: "/resume/{{ Auth::user()->id }}/job",
                    data: data.field,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 200) {
                            location.reload();
                        }

                    }
                });
                return true;
            });
            $('.layui-date').each(function () {
                laydate.render({
                    elem: this
                    , showBottom: false
                    , theme: '#dd4517'
                });
            });
            //编辑基本信息
            $('.basis-edit').click(function () {
                let parent = $(this).parents('.resume-item');
                parent.find('.default').toggle();
                parent.find('.default-edit').toggle();
            });
            $('.intention-edit').click(function () {
                let parent = $(this).parents('.resume-item');
                parent.find('.default').toggle();
                parent.find('.default-edit').toggle();
            });
            $('.module-add').click(function () {
                form.val("modal-job", {
                    "id": 0,
                    "company": '',
                    "salary": '',
                    "vocation_name": '',
                    "start_data": '',
                    "end_data": '',
                    "content": '',
                });
                let parent = $(this).parents('.resume-item');
                parent.find('.resume-module').toggle();
                parent.find('.resume-content').toggle();
            });
            $('.job-edit').click(function () {
                let parents = $(this).parents('.default');
                let id = $(this).data('id');
                form.val("form-job", {
                    "id": id,
                    "company": parents.find('.company_name').html().trim(),
                    "salary": parents.find('.wages').html().trim(),
                    "vocation_name": parents.find('.vocation_name').html().trim(),
                    "start_data": $('#d1').val(),
                    "end_data": $('#d2').val(),
                    "content": parents.find('.job-content').html().trim(),
                });
                let parent = $(this).parents('.resume-item');
                parent.find('.resume-module').toggle();
                parent.find('.resume-content').toggle();


            });

            function ajaxEditResume(params, module) {
                let parent = module.parents('.resume-item');
                $.ajax({
                    type: "Post",
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    url: "/resume/{{ Auth::user()->id }}/edit",
                    data: params,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 200) {
                            location.reload();
                        }

                    }
                });
            }

            $('.cancel').click(function () {
                let parent = $(this).parents('.resume-item');
                parent.find('.resume-module').toggle();
                parent.find('.resume-content').toggle();
            })
            // $('.edit').click(function () {
            //     $(this).parents('.resume-item').find('.default').toggle();
            //     $(this).parents('.resume-item').find('.default-edit').toggle();
            // })
            // $('.job>.layui-row').hover(function () {
            //     $(this).find('.edit').toggle();
            //     $(this).find('.time').toggle();
            // });

        })
    </script>


@endsection
